package com.xb.algorithm.service.impl;

import com.xb.algorithm.service.TokenGeneratorService;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

/**
 * @author xb
 * @descripton:
 * @date 2021/12/26
 */
@Service
public class Md5TokenGeneratorServiceImpl implements TokenGeneratorService {
    @Override
    public String generate(String... strings) {
        long timestamp = System.currentTimeMillis();
        String tokenMeta = "";
        for (String s : strings) {
            tokenMeta = tokenMeta + s;
        }
        tokenMeta = tokenMeta + timestamp;
        String token = DigestUtils.md5DigestAsHex(tokenMeta.getBytes());
        return token;
    }
}
